<script>
import { ElsCollapseItem } from "../collapse";
import BaseNode from "../../mixins/node.js";
export default {
  props: {
    activedId: String,
    fold: Boolean,
  },
  mixins: [BaseNode],
  data() {
    return {
      activeNames: [],
    };
  },
  computed: {
    actived() {
      return this.id === this.activedId;
    },
  },
  methods: {
    handleCommand(params, command) {
      if (command === "showhide") {
        params.handler();
      }
    },
    handlerExpand(handler) {
      handler();
      if (!this.actived) {
        this.$emit("clickedHandler", this.id);
      }
      // this.$emit("clickedHandler", this.id);
    },
    toggleChildren(evt) {
      // this.toggleFold(this.id);
      this.$emit("toggleFold", this.id);
    },
  },
  components: {
    ElsCollapseItem,
  },
};
</script>
<template>
  <div
    :class="['card-room', { actived }]"
    @click="$emit('clickedHandler', id)"
    :data-id="id"
  >
    <els-collapse-item class="collapse-item" :name="id">
      <template #header="{ isActive, handler }">
        <div class="top-right-d"></div>
        <div class="sch-dot --left" ref="leftDot">
          <!-- <i class="iconfont icon-plus-square-o"></i> -->
        </div>
        <div
          class="sch-dot --right"
          :class="{ '--fold': fold }"
          ref="rightDot"
          @click.stop="toggleChildren"
        >
          <!-- <i class="iconfont icon-plus-square-o"></i> -->
          <i
            :class="[
              'iconfont',
              fold ? 'icon-plus-square-o' : 'icon-minus-square',
            ]"
          ></i>
        </div>
        <div class="card-main-header">
          <div class="custom-header">
            <div class="--left">
              <i class="iconfont icon-Check-Circle-Fill"></i>
              <span>{{ data.name }}</span>
            </div>
            <div class="--right">
              <el-tooltip
                class="item"
                effect="dark"
                content="未发布"
                placement="top-start"
              >
                <i class="iconfont icon-fabusekuai published"></i>
              </el-tooltip>
              <el-dropdown
                trigger="click"
                @command="
                  (command) => handleCommand({ isActive, handler }, command)
                "
              >
                <i class="iconfont icon-androidgengduo-copy"></i>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item command="showhide"
                    >折叠/显示</el-dropdown-item
                  >
                  <el-dropdown-item>显示主刀分组</el-dropdown-item>
                  <el-dropdown-item>清空手术护士</el-dropdown-item>
                  <el-dropdown-item>清空麻醉医生</el-dropdown-item>
                  <el-dropdown-item>清空体外循环</el-dropdown-item>
                  <el-dropdown-item>清空手术安排</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
              <el-divider direction="vertical"></el-divider>
              <i
                @click.stop="handlerExpand(handler)"
                class="iconfont els-collapse-item__arrow icon-down"
                :class="{ 'is-active': isActive }"
              ></i>
            </div>
          </div>
          <div class="custom-sub-header">
            <span
              >计划 {{ data.totalCount }} 台 · 实际
              {{ data.startCount }} 台</span
            >
          </div>
        </div>
      </template>
      <div class="detail">
        <el-steps direction="vertical" :space="30" :active="3">
          <el-step icon="iconfont icon-Check-Circle-Fill">
            <div slot="title" class="step-content">
              <div class="step-left">
                <span>择期：共 {{ 100 }} 台 完成 {{ 100 }} 台</span>
              </div>
              <div class="step-right">
                <span>{{ "100%" }}</span>
              </div>
            </div>
          </el-step>
          <el-step icon="iconfont icon-jiazaiyuanhuan-ban">
            <div slot="title" class="step-content">
              <div class="step-left">
                <span>急诊：共 {{ 10 }} 台 完成 {{ 10 }} 台</span>
              </div>
              <div class="step-right">
                <span>{{ "100%" }}</span>
              </div>
            </div>
          </el-step>
          <el-step icon="iconfont icon-jiazaiyuanhuan-ban">
            <div slot="title" class="step-content">
              <div class="step-left">
                <span>日间：共 {{ 10 }} 台 完成 {{ 10 }} 台</span>
              </div>
              <div class="step-right">
                <span>{{ "50%" }}</span>
              </div>
            </div>
          </el-step>
          <el-step icon="iconfont icon-history">
            <div slot="title" class="step-content">
              <div class="step-left">
                <span>停台：无</span>
              </div>
              <div class="step-right">
                <span>{{ " " }}</span>
              </div>
            </div>
          </el-step>
        </el-steps>
      </div>
    </els-collapse-item>
  </div>
</template>
<style scoped lang="less">
.card-room {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.65);
  line-height: 20px;
  transition: all 0.3s linear;
  &.actived {
    > .collapse-item {
      ::v-deep {
        .els-collapse-item__header {
          border-color: rgba(22, 119, 255, 1);
          background: rgba(22, 122, 255, 0.09);
          .top-right-d {
            opacity: 1;
          }
        }
      }
    }
  }
  .collapse-item {
    transition: all 0.3s linear;
    background: #fff;
    ::v-deep {
      &.is-active {
        background: rgba(22, 122, 255, 0.09);
      }
      .els-collapse-item__header {
        border: 1px solid #d8d8d8;
        border-radius: 4px;
        position: relative;
        transition: all 0.3s linear;
        padding: 0px;
        background: #fff;
        &.is-active {
          // background: #409eff29;
          // border-color: #1677ff;
          border-color: rgba(22, 119, 255, 1);
          background: rgba(22, 122, 255, 0.09);
          .els-collapse-item__arrow {
            margin-top: -2px;
            transform: rotate(180deg);
          }
          .top-right-d {
            opacity: 1;
          }
        }
      }
    }
  }
  .top-right-d {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
    right: 1px;
    top: 1px;
    transition: opacity 0.3s linear;
    border-top-right-radius: 4px;
    border-top: 12px solid #1677ff;
    border-left: 12px solid transparent;
  }
  .card-main-header {
    padding: 8px;
    .custom-header {
      display: flex;
      align-items: center;
      padding-bottom: 2px;
      > .--left {
        flex: 1;
        font-size: 14px;
        display: flex;
        align-items: center;
        color: rgba(0, 0, 0, 0.85);
        .iconfont {
          color: #30a46c;
          margin-right: 5px;
        }
      }
      > .--right {
        display: flex;
        align-items: center;
        .iconfont {
          cursor: pointer;
          display: block;
          width: 14px;
          height: 20px;
          font-size: 14px;
          margin-right: 0;
          color: rgba(0, 0, 0, 0.45);
          &.icon-androidgengduo-copy {
            margin-left: 3px;
          }
          &.icon-fabusekuai.published {
            color: #30a46c;
          }
        }
        ::v-deep .el-divider {
          color: rgba(0, 0, 0, 0.06);
          margin-left: 5px;
        }
      }
    }
    .custom-sub-header {
      color: rgba(0, 0, 0, 0.45);
    }
  }
  .detail {
    padding: 8px;
    ::v-deep .el-step {
      &:last-child {
        flex-basis: 18px !important;
      }
      .el-step__head {
        width: 16px;
        &.is-finish {
          color: rgba(48, 164, 108, 1);
          border-color: rgba(48, 164, 108, 1);
        }
        &.is-process {
          color: rgba(0, 0, 0, 0.25);
          border-color: rgba(0, 0, 0, 0.25);
        }
        &.is-wait {
          color: rgba(0, 0, 0, 0.25);
          border-color: rgba(0, 0, 0, 0.25);
        }
      }
      .el-step__title {
        &.is-process {
          font-weight: normal;
        }
      }
      .el-step__line {
        left: 9px;
      }
      .el-step__icon {
        font-size: 14px;
        width: 20px;
        height: 20px;
        border-radius: 100%;
        background: #e7f1fe;
        padding: 3px;
      }
      .el-step__icon-inner {
        font-weight: unset;
        &.icon-Check-Circle-Fill {
          color: #30a46c;
        }
        &.icon-jiazaiyuanhuan-ban {
          color: #1677ff;
        }
      }
    }
    .step-content {
      display: flex;
      align-items: center;
      color: rgba(0, 0, 0, 0.65);
      line-height: 22px;
      font-size: 12px;
      > .step-left {
        flex: 1;
      }
      > .step-right {
        color: rgba(0, 0, 0, 0.45);
      }
    }
  }
}
</style>
